﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HPIT.RentHouse.Common
{
    public class AliyunSendSms
    {
        /**
          * 使用AK&SK初始化账号Client
          * @param accessKeyId
          * @param accessKeySecret
          * @return Client
          * @throws Exception
          */
        public static AlibabaCloud.SDK.Dysmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // 必填，您的 AccessKey ID
                AccessKeyId = accessKeyId,
                // 必填，您的 AccessKey Secret
                AccessKeySecret = accessKeySecret,
            };
            // 访问的域名
            config.Endpoint = "dysmsapi.aliyuncs.com";
            return new AlibabaCloud.SDK.Dysmsapi20170525.Client(config);
        }

        /**
        * 使用STS鉴权方式初始化账号Client，推荐此方式。本示例默认使用AK&SK方式。
        * @param accessKeyId
        * @param accessKeySecret
        * @param securityToken
        * @return Client
        * @throws Exception
        */
        public static AlibabaCloud.SDK.Dysmsapi20170525.Client CreateClientWithSTS(string accessKeyId, string accessKeySecret, string securityToken)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // 必填，您的 AccessKey ID
                AccessKeyId = accessKeyId,
                // 必填，您的 AccessKey Secret
                AccessKeySecret = accessKeySecret,
                // 必填，您的 Security Token
                SecurityToken = securityToken,
                // 必填，表明使用 STS 方式
                Type = "sts",
            };
            // 访问的域名
            config.Endpoint = "dysmsapi.aliyuncs.com";
            return new AlibabaCloud.SDK.Dysmsapi20170525.Client(config);
        }

    }
}
